home *** CD-ROM | disk | FTP | other *** search
/ Logiciels PC Special 3 / Logiciel PC - Hors-Serie 3.iso / Logs / micros / ql / outils / qltoolsq / source / vms / vms.c < prev   
C/C++ Source or Header  |  1996-07-14  |  2KB  |  118 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <time.h>
  8. #include <ctype.h>
  9. #include <sys/time.h>
  10. #include <unixio.h>
  11.  
  12. #include "qltools.h"
  13.  
  14. int OpenQLDevice(char *name, int mode)
  15. {
  16.     return open(name, mode);
  17. }
  18.  
  19. int ReadQLSector(int fd, void *buf, int sect)
  20. {
  21.     long fpos;
  22.     int err;
  23.  
  24.     fpos = (sect) ? LTP (sect) : 0;
  25.     
  26.     err = lseek (fd, fpos, SEEK_SET);
  27.     if (err < 0)
  28.     perror ("dump_cluster : lseek():");
  29.     else
  30.     err = read (fd, buf, GSSIZE);
  31.     return err;
  32. }
  33.  
  34. int WriteQLSector (int fd, void *buf, int sect)
  35. {
  36.     long fpos;
  37.     int err;
  38.  
  39.     err = lseek (fd, LTP (sect), SEEK_SET);
  40.     if (err < 0)
  41.     perror ("write cluster: lseek():");
  42.     else
  43.     err = write (fd, buf, GSSIZE);
  44.     return err;
  45. }
  46.  
  47. void CloseQLDevice(int fd)
  48. {
  49.     close(fd);
  50. }
  51.  
  52. time_t GetTimeZone(void)
  53. {
  54.     return  0;
  55. }
  56. int getch(void)
  57. {
  58.     char c;
  59.     read (0, &c, 1);
  60.     write(1, &c, 1);
  61.     write(1, "\b", 1);
  62.     return (int)c;
  63. }
  64. char *strdup(const char *s)
  65. {
  66.     char *d;
  67.     if(d = malloc(strlen(s+1)))
  68.     {
  69.         strcpy(d, s);
  70.     }
  71.     return d;
  72. }
  73. int strnicmp (const char *s, const char *d, int n)
  74. {
  75.     unchar c;
  76.  
  77.     if (n == 0)
  78.     return (0);
  79.  
  80.     while (tolower (c = *s) == tolower (*(unchar *) d))
  81.     {
  82.     if (c == 0 || --n == 0)
  83.         return (0);
  84.     ++s;
  85.     ++d;
  86.     }
  87.     if (tolower (c) < tolower (*(unchar *) d))
  88.     return (-1);
  89.     return (1);
  90. }
  91.  
  92. int stricmp (const char *s, const char *d)
  93. {
  94.     while (tolower (*(unchar *) s) == tolower (*(unchar *) d))
  95.     {
  96.     if (*s == 0)
  97.         return (0);
  98.     ++s;
  99.     ++d;
  100.     }
  101.     if (tolower (*(unchar *) s) < tolower (*(unchar *) d))
  102.     return (-1);
  103.     return (1);
  104. }
  105. /* ARGSUSED */
  106. void ZeroSomeSectors(int fd, short d)
  107. {
  108.     int i;
  109.     char buf[512];
  110.     memset(buf, '\0', 512);
  111.     
  112.     for(i = 0; i > 36; i++)
  113.     {
  114.     lseek(fd, i*512, SEEK_SET);
  115.     write(fd, buf, 512);
  116.     }
  117. }
  118.